Builder
Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts.
On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.
For example, action buttons won't appear on platforms prior to Android 4.1. Action buttons depend on expanded notifications, which are only available in Android 4.1 and later.
For this reason, you should always ensure that UI controls in a notification are also available in an android.app.Activity in your app, and you should always start that android.app.Activity when users click the notification. To do this, use the setContentIntent() method.
Constructors
Functions
Link copied to clipboard
open fun addAction(icon: Int, @Nullable title: CharSequence, @Nullable intent: PendingIntent): NotificationCompat.Builder
Add an action to this notification.
Link copied to clipboard
open fun addInvisibleAction(@Nullable action: NotificationCompat.Action): NotificationCompat.Builder
open fun addInvisibleAction(icon: Int, @Nullable title: CharSequence, @Nullable intent: PendingIntent): NotificationCompat.Builder
Add an invisible action to this notification.
Link copied to clipboard
Combine all of the options that have been set and return a new Notification object.
Link copied to clipboard
Clear any actions added via addAction
Link copied to clipboard
Clear any invisible actions added via addInvisibleAction
Link copied to clipboard
Link copied to clipboard
Construct a RemoteViews for the final big notification layout.
Link copied to clipboard
Construct a RemoteViews for the final notification layout.
Link copied to clipboard
Construct a RemoteViews for the final heads-up notification layout.
Link copied to clipboard
Apply an extender to this notification builder.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
return when if it is showing or 0 otherwise
Link copied to clipboard
Determines whether the platform can generate contextual actions for a notification.
Link copied to clipboard
Setting this flag will make it so the notification is automatically canceled when the user clicks it in the panel.
Link copied to clipboard
Sets which icon to display as a badge for this notification.
Link copied to clipboard
open fun setBubbleMetadata(@Nullable data: NotificationCompat.BubbleMetadata): NotificationCompat.Builder
Sets the BubbleMetadata that will be used to display app content in a floating window over the existing foreground activity.
Link copied to clipboard
Set the notification category.
Link copied to clipboard
Specifies the channel the notification should be delivered on.
Link copied to clipboard
Sets the Chronometer to count down instead of counting up.
Link copied to clipboard
Set whether this notification should be colorized.
Link copied to clipboard
Supply a custom RemoteViews to use instead of the standard one.
Link copied to clipboard
A small piece of additional information pertaining to this notification.
Link copied to clipboard
Supply a PendingIntent to send when the notification is clicked.
Link copied to clipboard
Set the text (second row) of the notification, in a standard notification.
Link copied to clipboard
Set the title (first row) of the notification, in a standard notification.
Link copied to clipboard
Supply custom RemoteViews to use instead of the platform template in the expanded form.
Link copied to clipboard
Supply custom RemoteViews to use instead of the platform template.
Link copied to clipboard
open fun setCustomHeadsUpContentView(@Nullable contentView: RemoteViews): NotificationCompat.Builder
Supply custom RemoteViews to use instead of the platform template in the heads up dialog.
Link copied to clipboard
Set the default notification options that will be used.
Link copied to clipboard
Supply a PendingIntent to send when the notification is cleared by the user directly from the notification panel.
Link copied to clipboard
Specify a desired visibility policy for a Notification associated with a foreground service.
Link copied to clipboard
open fun setFullScreenIntent(@Nullable intent: PendingIntent, highPriority: Boolean): NotificationCompat.Builder
An intent to launch instead of posting the notification to the status bar.
Link copied to clipboard
Sets the group alert behavior for this notification.
Link copied to clipboard
Set this notification to be the group summary for a group of notifications.
Link copied to clipboard
Sets the large icon that is shown in the notification.
Link copied to clipboard
Set whether or not this notification is only relevant to the current device.
Link copied to clipboard
Sets the LocusIdCompat associated with this notification.
Link copied to clipboard
Silences this instance of the notification, regardless of the sounds or vibrations set on the notification or notification channel.
Link copied to clipboard
Sets the number of items this notification represents.
Link copied to clipboard
Set whether this is an ongoing notification.
Link copied to clipboard
Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing.
Link copied to clipboard
Set the relative priority for this notification.
Link copied to clipboard
Set the progress this notification represents, which may be represented as a android.widget.ProgressBar.
Link copied to clipboard
Supply a replacement Notification whose contents should be shown in insecure contexts (i.e.
Link copied to clipboard
Set the remote input history.
Link copied to clipboard
Provides text that will appear as a link to your application's settings.
Link copied to clipboard
From Android 11, messaging notifications (those that use MessagingStyle) that use this method to link to a published long-lived sharing shortcut may appear in a dedicated Conversation section of the shade and may show configuration options that are unique to conversations.
Link copied to clipboard
Populates this notification with given ShortcutInfoCompat.
Link copied to clipboard
Control whether the timestamp set with setWhen is shown in the content view.
Link copied to clipboard
If
true
, silences this instance of the notification, regardless of the sounds or vibrations set on the notification or notification channel.Link copied to clipboard
Set the small icon to use in the notification layouts.
A variant of setSmallIcon(int) that takes an additional level parameter for when the icon is a LevelListDrawable.
Link copied to clipboard
Set a sort key that orders this notification among other notifications from the same package.
Link copied to clipboard
Add a rich notification style to be applied at build time.
Link copied to clipboard
This provides some additional information that is displayed in the notification.
Link copied to clipboard
open fun setTicker(@Nullable tickerText: CharSequence, @Nullable views: RemoteViews): NotificationCompat.Builder
Sets the "ticker" text which is sent to accessibility services.
Link copied to clipboard
Specifies the time at which this notification should be canceled, if it is not already canceled.
Link copied to clipboard
Show the when field as a stopwatch.
Link copied to clipboard
Set the vibration pattern to use.
Link copied to clipboard
Sets visibility.
Link copied to clipboard
Set the time that the event occurred.